home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / texsis / TXSpatch.tex < prev   
Text File  |  1993-12-02  |  21KB  |  415 lines

  1. %% file: TXSpatch.tex                                    TeXsis 2.15/m
  2. %  $Revision: 16.12 $  :  $Date: 93/12/03 10:32:55 $  :  $Author: myers $
  3. %======================================================================*
  4. % The file TXSpatch.tex is read in by texsis at run time, if it
  5. % exists.  These patches correct minor problems which will be fixed
  6. % in the next release of TeXsis.  
  7.  
  8. %%\def\revdate{13 August 1992}\def\fmtversion{2.15/c}%
  9. %%\def\revdate{29 September 1992}\def\fmtversion{2.15/d}%
  10. %%\def\revdate{10 October 1992}\def\fmtversion{2.15/e}%
  11. %%\def\revdate{12 October 1992}\def\fmtversion{2.15/f}%
  12. %%\def\revdate{20 November 1992}\def\fmtversion{2.15/g}%
  13. %%\def\revdate{1 March 1993}\def\fmtversion{2.15/h}%
  14. %%\def\revdate{5 May 1993}\def\fmtversion{2.15/i}%
  15. %%\def\revdate{16 October 1993}\def\fmtversion{2.15/j}%
  16. %%\def\revdate{19 November 1993}\def\fmtversion{2.15/k}%
  17. \def\revdate{3 December 1993}\def\fmtversion{2.15/m}%
  18.  
  19. \ATunlock       % make @ a letter for "hidden" macro names
  20.  
  21. %==================================================*
  22. % Patch a:  Reference citations and numbering
  23. %
  24. % In citations to equation numbers which have letters in them the
  25. % letters should be in (math) italics, just as in the original equation
  26. % number.  Thus the citation macros should put \use in math quotes.  
  27.  
  28. \def\Eq#1{Eq.~($\use{Eq.#1}$)}          % \Eq  prints  "Eq. (nn)"
  29. \def\Eqs#1{Eqs.~($\use{Eq.#1}$)}        % \Eqs prints  "Eqs. (nn)"
  30. \def\Ep#1{($\use{Eq.#1}$)}              % \Ep  prints just "(nn)"
  31.  
  32.  
  33. % Also, \frac got changed, so change it back to what it used to be
  34.  
  35. \def\frac#1#2{{#1\over #2}}
  36.  
  37.  
  38. % Not a bug patch, but a nice improvement.  The following code
  39. % causes \ListReferences to reset everything so that you can
  40. % continue collecting references.  The counters are reset to zero
  41. % and \refint is re-initialized so that it will re-open the .ref file.
  42. % [Thanks to Betty A for suggesting this.  It will be a part of the
  43. % next release.]
  44.  
  45. % \refReset resets the counters so that more references can be created
  46. % after \ListReferences has been called.  For example, if you listed the
  47. % references for one chapter and want to begin collecting references for
  48. % the next chapter. 
  49.  
  50. \def\refReset{% reset reference/citation counters
  51.    \global\refnum=\z@                           % counter for reference numbers
  52.    \global\@firstrefnum=1                       % first of a series of refs
  53.    \global\@lastrefnum=1                        % last of a series of refs
  54.    \global\@BadRefs=0                           % count undefined references
  55.    \gdef\refinit{\@refinit}%                    % re-enable \refinit
  56.    }
  57.  
  58. % need to change \refinit so it can be turned on again later, if
  59. % need be.
  60.  
  61. \def\@refinit{\ifrefswitch               % is .ref ouput enabled?
  62.    \immediate\openout\reflistout=\jobname.ref  % y: open .ref file for output
  63.   \else                                 % no:
  64.     \let\@refwrite=\@refwrong           %   disable output
  65.     \let\@refNXwrite=\@refwrong         %   disable output
  66.     \immediate\closeout\reflistout      % and make sure output closed
  67.   \fi                                   %
  68.   \gdef\refinit{\relax}%                % disable \refinit once it's done
  69. }%
  70.  
  71. \def\refinit{\@refinit}                 % start with \refinit enabled
  72.  
  73. %==================================================*
  74. % Patch b:  fix \EQNdisplaylines
  75. %
  76. % previous version of \EQNdisplaylines did not work like \displaylines
  77. % when it came to left justifying equations with \hfill. This one does.  
  78.  
  79. \def\EQNdisplaylines#1{%                % make \EQN re-\def local
  80.    \@EQNcr                              % change \def of \EQN to get label
  81.    \displ@y                             % reduce interline spacing (from Plain)
  82.    \halign{%                            % alignment
  83.       \hbox to\displaywidth{%           % full width
  84.       $\@lign\hfil\displaystyle##\hfil$}% centered displaystyle
  85.       &\llap{$\@lign\@@EQN{##}$}\crcr   % then eqn number template
  86.    #1\crcr}%                            % now apply template to argument
  87.    \@EQNuncr}                           % put \EQN back to normal
  88.  
  89.  
  90. %==================================================*
  91. % Patch c: fix the problem with \@eatpar eating \def's 
  92. %
  93. % \@eatpar gets rid of any \par that follows.  We have to use \futurelet
  94. % to avoid problems when what follows is a \def or somesuch.
  95.      
  96. \def\@eatpar{\futurelet\next\@testpar}
  97. \def\@testpar{\ifx\next\par\let\@next=\@@eatpar\else\let\@next=\relax\fi\@next}
  98. \long\def\@@eatpar#1{\relax}
  99.  
  100. %==================================================*
  101. % patch d:  \loadstyle fails on PC-TeX and NorthLake TeX, so..
  102. %
  103. % Previously \loadstyle used \openin to try to determine if the style
  104. % file to load existed.  If it could not be opened then \ifeof would be
  105. % true.  However, some implementations of TeX do not look through the
  106. % whole TEXINPUTS path for \openin (as they do for \input) so this is
  107. % not a reliable test.  We consider this a bug, but we have to live with
  108. % it until those guys get their TeX fixed!  So now we just use \input to
  109. % read the style file.  But if \openin can't find the file we at least
  110. % say what we are trying to do, in case it does fail.  
  111.  
  112. \newread\txsfile                % to help look for style files
  113.  
  114. \def\loadstyle#1#2{%            % load a definition for #1 from file #2
  115.    \def#1{\@loaderr{#1}}%       % disable #1 (just in case...)
  116.    \ATunlock                    % make @ a letter, in case it's in the file
  117.    \immediate\openin\txsfile=#2 % try to open the file to see if it exists
  118.    \ifeof\txsfile               % if end of file, then print a message
  119.       \emsg{> Trying to load the style file #2...}% before trying to \input
  120.    \fi                          %
  121.    \closein\txsfile             % just close the file in any case
  122.    \input #2 \relax             % load (or try to) the file with the new \def
  123.    \ATlock                      % @ now no longer a letter
  124.    #1}                          % now use the new definitions
  125.  
  126.  
  127. %==================================================*
  128. % patch e: \@BadTags and \@BadRefs should use \global\advance
  129. %
  130. % in TXStags.tex:
  131.  
  132. \def\@use#1{%   does the work for \use
  133.    \endgroup                                    % end unspecial characters
  134.    \stripblanks @#1@\endlist                    % @name@ -> \tok w/o blanks
  135.    \XA\ifx\csname\tok\endcsname\relax\relax     % is \@name@ undefined?
  136.      \emsg{> UNDEFINED TAG #1 ON PAGE \folio.}% % yes: error message
  137.      \global\advance\@BadTags by 1              % count how many
  138.      \@errmark{UNDEF}%                          %   and mark in output
  139.      \edef\tok{{\bf\tok}}%                      % and return \bf ``name''
  140.    \else                                        % else:
  141.      \edef\tok{\csname\tok\endcsname}%          %  get the definition
  142.    \fi                                          %
  143.    \tok}                                        % evaluate it
  144.  
  145.  
  146. % in TXSrefs.tex:
  147.  
  148. \def\make@refmark#1{% make a reference mark
  149.   \testtag{Ref.#1}\ifundefined           % is it undefined? (tag -> \tok)
  150.     \emsg{> UNDEFINED REFERENCE #1 ON PAGE \number\pageno.}% error message
  151.     \global\advance\@BadRefs by 1        % count undefined references
  152.     \xdef\@refmark{{\tenbf #1}}%         % cite with label in boldface
  153.     \@errmark{REF?}%                     % and mark error in output
  154.   \else                                  % no:
  155.     \xdef\@refmark{\csname\tok\endcsname}%  cite with number
  156.   \fi}                                   % end of \ifundefined
  157.  
  158.  
  159. %==================================================*
  160. % patch f:  TXSfigs.tex
  161. %
  162. % \infiglist and \intablelist were getting page numbers wrong
  163. % when many figures were inserted.  The problem was the page number
  164. % (\folio) was being evaluated when the macro was called, not when the
  165. % \write to the file was actually being performed.  Inserting one
  166. % \noexpand solves the problem.
  167.  
  168.  
  169. \def\@infiglist#1#2{% write to list of figures or tables
  170.    \FigListWrite#1{\@comment}%                  % comment '%'
  171.    \FigListWrite#1{\@comment \CaptionName\space\@ID:}% comment '%'
  172.    \FigListWrite#1{\NX\NX\NX\FIGLitem{\CaptionName} {\@ID.\space}}% 
  173.    \FigListWriteNX#1{{#2}}%      the caption text should not be expanded at all!
  174.    \FigListWrite#1{{\NX\folio}}% the page number, so don't expand until written
  175.    \endgroup}                                   % end \obeylines
  176.  
  177. %==================================================*
  178. % patch g:  TXSrefs.tex (supersceded by patch j)
  179. %
  180. %==================================================*
  181. % patch h:  TXSfmts.tex
  182. %
  183. % \Manuscript was just \preprint with true double spacing, but Phys.
  184. % Rev. is now more specific about how submitted manuscripts should
  185. % appear.  Further improvements or suggestions are welcome, and we'll
  186. % keep working on this.
  187.  
  188. \def\Manuscript{% layout for manuscripts to be submitted to journals
  189.    \preprint                    % start with preprint form
  190.    \showsectIDfalse             % no section number in equation numbers
  191.    \showchaptIDfalse            % no chapter number in equation numbers
  192.    \def\SectionStyle##1{\uppercase       % section numbers in upper case
  193.          \expandafter{\romannumeral ##1}}%     roman numerals
  194.    \RomanTablestrue             % roman numerals for table numbers
  195.    \TablesLast                  % tables at the end
  196.    \FiguresLast                 % figures at the end
  197.    \TrueDoubleSpacing           % wider interline spacing for manu
  198.    }
  199.  
  200.  
  201. %% TXSfigs.tex:  
  202.  
  203. %  \ListFigureCaptions uses a modified \FIGLitem and the figure list file
  204. %  to list just the captions, but without the page numbers.  Use this
  205. %  at the end of your document to get a list of all the captions.
  206.  
  207. \def\ListFigureCaptions{%  print figure captions only, no page numbers
  208.    \showsectIDtrue                              % do print ``Figure''
  209.    \emsg{\@comment List of Figure Captions:}%   % message
  210.    \immediate\closeout\figlist                  % close caption list file
  211.    \openin\figlist=\jobname.fgl                 % reopen to read it 
  212.    \ifeof\figlist\closein\figlist               % if EOF just close it
  213.       \emsg{> \NX\ListFigureCaptions: no list of figures.}%  and complain
  214.    \else\closein\figlist                        % else close it and 
  215.      \begingroup                                % read it in...
  216.       \ATunlock\quoteoff\offparens              % \specials not active
  217.       \let\FIGLitem=\CAPLitem                   % use modified \FIGLitem
  218.       \Input\jobname.fgl \relax                 % read in captions
  219.      \endgroup                                  %
  220.    \fi}                                                  % else ignore it
  221.  
  222.  
  223.  
  224. % \CAPLitem is like \FIGLitem above, but it just ignores #4
  225.  
  226. \def\CAPLitem#1#2#3#4{% Figure or Table list item for list of captions
  227.    \medskip                                     % some space between items
  228.    \begingroup                                  %
  229.      \raggedright\tolerance=1700                % don't justify
  230.      \advance\rightskip by \TOCmargin           % right margin comes in, but
  231.      \parfillskip=-\TOCmargin                   % page number at edge of page
  232.      \hangindent=1.41\parindent\hangafter=1     % hanging indentation
  233.      \noindent \ifshowsectID #1\ \fi #2         % show section numbers
  234.         #3 \hskip 0pt plus 10pt                 % text of ``caption''
  235.      \vskip 0pt                                 % end paragraph
  236.    \endgroup}                                   %
  237.  
  238. %==================================================*
  239. % patch i:
  240. %
  241. % TXSenvmt.tex:   \Listing was fixed in patch e so that ~ was not active.
  242. % This fixes the spacing problems and adds \everyListing
  243.  
  244. \def\Listing{%  environment for listing computer code verbatim in \tt
  245.    \beginEnv{Listing}%                          %
  246.    \vskip\EnvDelt@skip                          % do extra skip
  247.    \baselineskip=\normalbaselineskip            % singlespaced
  248.    \parskip=\z@ \parindent=\z@                  % set \par indentation to zero
  249.    \def\\##1{\char92##1}%                       % \ for macro names
  250.    \catcode`\{=\other \catcode`\}=\other        % { and } just characters
  251.    \catcode`\(=\other \catcode`\)=\other        % ( and ) just characters
  252.    \catcode`\"=\other \catcode`\|=\other        % " and | just characters
  253.    \catcode`\%=\other \catcode`\&=\other        % so %  and & are characters
  254.    \catcode`\-=\other \catcode`\==\other        % so -  and = are characters
  255.    \catcode`\$=\other \catcode`\#=\other        % so $  and # are characters
  256.    \catcode`\_=\other \catcode`\^=\other        % so _  and ^ are characters
  257.    \catcode`\~=\other \catcode`\ =\other        % ~ is not active tie!
  258.    \obeylines                                   % obey line endings,
  259.    \tt\Listingtabs                              % spaces and tabs   
  260.    \everyListing}                               % user customization
  261.  
  262. %  Use \everyListing to customize your \Listing.  
  263.  
  264. \def\everyListing{}
  265.  
  266. % Use \ListCodeFile{<filename>} to directly include a source file
  267. % in the document.  Use this INSTEAD of \Listing, not after it.
  268. % Nothing in this file is ``active,'' so you cannot have TeX commands
  269. % in the file.  Example:  \ListCodeFile{hello.c}
  270.  
  271. \def\ListCodeFile#1{%  print the named file verbatim using \Listing
  272.    \Listing                             % invoke \Listing and read in file
  273.    \hsize=2\hsize\raggedright           % allow overflow in right margin
  274.    \catcode`\\=\other                   % \ is not active!
  275.    \input #1\relax                      % read in source file
  276.    \endListing}
  277.  
  278. {\catcode`\^^I=\active\catcode`\ =\active% no spaces in any of this!
  279. \gdef\Listingtabs{\catcode`\^^I=\active\let^^I\@listingtab%
  280. \catcode`\ =\active\let \@listingspace}%
  281. }%\global\let^^I\@listingtab}%
  282.  
  283. \def\@listingspace{\hskip 0.5em}                % \tt space is 0.5em
  284.  \def\@listingtab{\hskip 4em}                    % eight spaces per tab
  285.  
  286. % TXSdcol.tex:  a \pageinsert in double column mode should still give
  287. % a full page insert, while \fullinsert does a full *column*.
  288. % A more complete overhaul of inserts in double columns will appear
  289. % in 2.16.
  290.  
  291. \def\@doublecolumns{%                           % begin 2 columns
  292.    \begingroup                                  % keep changes local
  293.    \def\endmode{\@enddoublecolumns}             % how to end 
  294.    \output={\global\setbox\partialpage=%        % set up output
  295.       \vbox{%                                   % box containing...
  296.          \ifvoid\topins\else\unvbox\topins\fi%  %top insert
  297.          \unvbox255}}\eject                     % and main page
  298.    \output={\d@ublec@lumnout}%                  % set 2 column output
  299.    \long\def\fullfigure{\@figure\fullpageinsert}% full figures on full page
  300.    \s@vesize=\vsize                             % save old \vsize
  301.    \hsize=\colwidth\vsize=\bigc@lheight         % set width, 2*height
  302.    \advance \vsize by -2\ht\partialpage         %   less partial page
  303.    \advance \vsize by -2\dp\partialpage         %   less partial page
  304.    \global\s@veskip=\spaceskip                  % save old interword glue
  305.    \global\spaceskip=\doublecolskip             % stretch for small cols.
  306.    \global\displaywidth=\colwidth               % equations have \colwidth
  307.    \global\hyphenpenalty=0                      % hyphens are OK
  308.    \let\topinsert=\topinsertd@uble              % 2-col top insert
  309.    \global\let\midinsert=\midinsertd@uble       %   mid insert
  310.    \global\let\fullinsert=\pageinsertd@uble     %   full column insert
  311.    \global\let\pageinsert=\fullpageinsert       %   full PAGE insert
  312.    \global\let\endinsert=\endinsertd@uble       % 2-col end inserts
  313.    \global\let\widetopinsert=\widet@pinsert     % allow wide inserts
  314.    \global\let\widepageinsert=\widep@geinsert   % or full page inserts
  315.    \global\let\newcolumn=\@newcolumn            % to break columns
  316. }
  317.  
  318.  
  319. %==================================================*
  320. % patch j:  16 October 1993  -EAM
  321. %
  322. % TXSrefs.tex: problems with -- in \citemark, and with \refrange spacing
  323.  
  324. \def\citemark#1{% output the citation marks in the text
  325.    \relax\let\@sf\empty                         %
  326.    \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi % save spacefactor
  327.    \ifsuperrefs                                 % superscript references?
  328.       $\relax{}^{\hbox{$\citestyle               % small numbers
  329.            #1\refterminator$}}$\relax            % superscript
  330.    \else                                        %
  331.       {}~[{#1}]\relax                           % [] style
  332.    \fi                                          %
  333.    \@sf}%                                       % restore spacefactor
  334.  
  335. % Use en dash in \refrange rather than hyphen. (Betty A and Tim Pearce)
  336.  
  337. \long\def\refrange#1#2#3{% cites a range of references
  338.   \reffollowsfalse                      % assume no ref. follows
  339.   \ifx#3\cite\reffollowstrue\fi         % is next token another \cite?
  340.   \ifx#3\ref\reffollowstrue\fi          % (or \ref, OLD TeXsis)
  341.   \ifx#3\reference\reffollowstrue\fi    % or is it \reference? then set flag.
  342.   \ifx#3\refrange\reffollowstrue\fi     % or \refrange
  343. % --- construct reference mark in \@refmark
  344.   \make@refmark{#2}%                    % ref mark for 2nd ref
  345.   \xdef\@refmarktwo{\@refmark}%         % save for later
  346.   \make@refmark{#1}%                    % ref mark for 1st ref
  347.   \xdef\@refmark{\@refmark\hbox{--}\@refmarktwo}% create range of references
  348. %
  349.   \add@refmark                          % add to \@refmarklist
  350.   \flush@reflist{#3}%                   % flush output list
  351.   #3}%                                  % do the remaining #3 args
  352.  
  353. \newlinechar=`\^^M                  % <CR> breaks lines in file output
  354. \def\Afour{\hsize=16.5cm \vsize=24.5cm} % A4 paper size
  355.  
  356. %==================================================*
  357. % patch k:  19 November 1993  -EAM
  358. %
  359. % TXSrefs.tex: problems with \endreference followed by punctuation
  360.  
  361. \long\def\@endreference#1{% end a \reference and look ahead at next token
  362.   \reffollowsfalse                              % assume no cit'ns follow
  363.   \ifx#1\cite\reffollowstrue\fi                 % is next token another \cite?
  364.   \ifx#1\refrange\reffollowstrue\fi             % or \refrange
  365.   \ifx#1\ref\reffollowstrue\fi                  % (or \ref, OLD TeXsis)
  366.   \ifx#1\reference\reffollowstrue               % if \reference set flag
  367.   \else                                         %     but nothing more
  368.    \ifnum\@firstrefnum>\@lastrefnum\relax       % If *'d \reference, \relax
  369.    \else\ifmarkit                               % so can we write citation?
  370. % --- construct the reference mark for this reference or range in \@refmark
  371.     \ifnum\@firstrefnum=\@lastrefnum            % is there only one reference?
  372.       \xdef\@refmark{\the\@lastrefnum}%         % yes: write only one number
  373.     \else                                       % no: write a 
  374.       \xdef\@refmark{\the\@firstrefnum-\the\@lastrefnum}% range of numbers
  375.     \fi                                         % end \ifnum
  376.     \global\@firstrefnum=\refnum                % reset \@firstrefnum to be
  377.     \global\advance\@firstrefnum by \@ne        %   \refnum + 1
  378. %
  379.     \add@refmark                        % add \@refmark to \@refmarklist
  380.    \fi\fi                               % end \ifnum and \ifmarkit
  381.   \fi                                   % end \ifx#1\reference
  382.   \flush@reflist{#1}%                   % output ref mark list
  383.   \def\@next{#1}\ifcat.\NX#1\def\@next{#1 }\fi % space after if punctuation
  384.   \@next}                                  % do the remaining #1 lookahead
  385.  
  386. %==================================================*
  387. % patch m:  3 December 1993  -EAM
  388. %
  389. % TXSfigs.tex: list of table captions was trying to read wrong file
  390.  
  391. %  \ListTableCaptions is just like \ListFigureCaptions but for the 
  392. % list of table captions.
  393.  
  394. \def\ListTableCaptions{%  print table captions only, no page numbers
  395.    \showsectIDtrue                              % do print ``Table''
  396.    \emsg{\@comment List of Table Captions:}%    % message
  397.    \immediate\closeout\figlist                  % close caption list file
  398.    \openin\figlist=\jobname.tbl                 % reopen to read it 
  399.    \ifeof\figlist\closein\figlist               % if EOF just close it
  400.       \emsg{> \NX\ListFigureCaptions: no list of figures.}%  and complain
  401.    \else\closein\figlist                        % else close it and 
  402.      \begingroup                                % read it in...
  403.       \ATunlock\quoteoff\offparens              % \specials not active
  404.       \let\FIGLitem=\CAPLitem                   % use modified \FIGLitem
  405.       \Input\jobname.tbl \relax                 % read in captions
  406.      \endgroup                                  %
  407.    \fi}                                                  % else ignore it
  408.  
  409. %======================================================================*
  410. \ATlock         % make @ not a letter (hides internal macros).
  411.  
  412. \emsg{Patched to Version \fmtversion, \revdate.}%
  413.  
  414. %>>> EOF TXSpatch.tex
  415.